package com.ghpt.controller;
import com.ghpt.pojo.CoalEmission;
import com.ghpt.service.CoalEmissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;


@RestController
@RequestMapping("/coal")
public class CoalEmissionController {
    private final CoalEmissionService coalEmissionService;

    public CoalEmissionController(CoalEmissionService coalEmissionService) {
        this.coalEmissionService = coalEmissionService;
    }
    @GetMapping("/{id}")
    public CoalEmission getCoalEmissionById(@PathVariable Long id) {
        System.out.println("结果是"+coalEmissionService.findCoalEmissionById(id));
        return coalEmissionService.findCoalEmissionById(id);
    }
    @PutMapping
    public int updateCoalEmission(@RequestBody CoalEmission coalEmission) {
        return coalEmissionService.updateById(coalEmission);
    }
}
